﻿Imports System.Windows.Forms
Imports CodeDefinition

Public Class Options

    Private _ApplicationObject As ApplicationObject
    Public Property ApplicationObject() As ApplicationObject
        Get
            Return _ApplicationObject
        End Get
        Set(ByVal value As ApplicationObject)
            _ApplicationObject = value
            'bind
            cboboxGeneratorOutput.SelectedValue = value.GeneratorType
            chkboxBlankLines.Checked = value.BlankLinesBetweenMembers
            chkboxVerbatimOrder.Checked = value.VerbatimOrder
        End Set
    End Property


    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        ApplicationObject.GeneratorType = cboboxGeneratorOutput.SelectedValue
        ApplicationObject.BlankLinesBetweenMembers = chkboxBlankLines.Checked
        ApplicationObject.VerbatimOrder = chkboxVerbatimOrder.Checked
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub Options_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'create the combobox entriesv
        AddComboBoxItem(cboboxGeneratorOutput, "Visual Basic", ApplicationObject.enmGeneratorType.VisualBasic)
        AddComboBoxItem(cboboxGeneratorOutput, "C#", ApplicationObject.enmGeneratorType.CSharp)
        AddComboBoxItem(cboboxGeneratorOutput, "VB and C#", ApplicationObject.enmGeneratorType.VisualBasicAndCSharp)
    End Sub

    Private Sub AddComboBoxItem(ByVal acomboBox As ComboBox, ByVal aValue As String, ByVal aKey As ApplicationObject.enmGeneratorType)
        Dim myKVP As New KeyValuePair(Of String, ApplicationObject.enmGeneratorType)(aKey, aValue)
        acomboBox.Items.Add(myKVP)
    End Sub

End Class
